<?php
function form_update_post_type($id){
	global $jamnews;
	$current_tab = _val("current_tab");
	$pt = $jamnews->db_get_post_type($id);
	$datas = $pt->meta_value;
	$type  = $pt->meta_key;
	$name = ($datas['label']&&$datas['label']!="")?$datas['label']:$type;
	if( $datas['labels'] && $datas['labels']['name']!="" ){
		$name = $datas['labels']['name'];
	}
	
	$capability_type = (!$datas['capability_type']||$datas['capability_type']=="")?"post":$datas['capability_type'];
	
	// Tab labels
	$tab_labels = array(
		'general' => __('General','jamnews'),
		'labels' => __('Labels ','jamnews'),
		'advanced' => __('Advanced','jamnews'),
		'capabilities' => __('Capabilities','jamnews'),
		'fields' => __('Groups/Fields ','jamnews'),
	);
	
	// Tabs fields
	$tab_fields = array(
		'general' => array(
			array(	'title' => __('Basic Options',"jamnews"), 
					'type' => 'title' ),
				   
			array( 	'name'	=> 'post_type',
					'title' => __('Post type','jamnews'),
					'type' => 'text',
					'id' => 'post_type',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('Max. 20 characters, can not contain capital letters or spaces.','jamnews'),
					'default' =>  $type ),
				   
			array( 	'name'	=> 'label',
					'title' => __('Label','jamnews'),
					'type' => 'text',
					'id' => 'label',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' =>  __('max. 20 characters, can not contain capital letters or spaces','jamnews'), 
					'default' => $datas['label'] ),
			

			array( 	'name'	=> 'description',
					'title' => __('Description','jamnews'),
					'type' => 'textarea',
					'id' => 'description',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'default' =>  __( $datas['description'],"jamnews") ),
				   
			array(	'name'	=>'supports[title]',
					'title' => __( 'Supports', 'jamnews' ),
					'desc' 		=> __( '\'Title\'', 'jamnews' ),
					'id' 		=> 'supports_title',
					'default'	=> (in_array("title",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'	=> 'start'
			),
			
			array(	'name'	=> 'supports[editor]',
					'desc' 		=> __( '\'Editor\' (content) ', 'jamnews' ),
					'id' 		=> 'supports_editor',
					'default'	=> (in_array("editor",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name' 		=> 'supports[author]',
					'desc' 		=> __( '\'Author\'', 'jamnews' ),
					'id' 		=> 'supports_author',
					'default'	=> (in_array("author",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'	=>	'supports[thumbnail]',
					'desc' 		=> __( '\'Thumbnail\' (featured image, current theme must also support <a target="_blank" href="http://codex.wordpress.org/Post_Thumbnails">post-thumbnails</a>) ', 'jamnews' ),
					'id' 		=> 'supports_thumbnail',
					'default'	=> (in_array("thumbnail",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'	=> 	'supports[excerpt]',
					'desc' 		=> __( '\'Excerpt\'', 'jamnews' ),
					'id' 		=> 'supports_excerpt',
					'default'	=> (in_array("excerpt",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name' 		=> 'supports[trackbacks]',
					'desc' 		=> __( '\'Trackbacks\'', 'jamnews' ),
					'id' 		=> 'supports_trackbacks',
					'default'	=> (in_array("trackbacks",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name' 		=> 'supports[custom-fields]',
					'desc' 		=> __( '\'Custom fields\'', 'jamnews' ),
					'id' 		=> 'supports_custom-fields',
					'default'	=> (in_array("custom-fields",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[comments]',
					'desc' 		=> __( '\'Comments\' (also will see comment count balloon on edit screen) ', 'jamnews' ),
					'id' 		=> 'supports_comments',
					'default'	=> (in_array("comments",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 'supports[revisions]',
					'desc' 		=> __( '\'Revisions\' (will store revisions) ', 'jamnews' ),
					'id' 		=> 'supports_revisions',
					'default'	=> (in_array("revisions",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name' 		=> 'supports[page-attributes]',
					'desc' 		=> __( '\'Page Attributes\' (menu order, hierarchical must be true to show Parent option) ', 'jamnews' ),
					'id' 		=> 'supports_page-attributes',
					'default'	=> (in_array("page-attributes",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> '' ),
			
			array(	'name'		=> 	'supports[post-formats]',
					'desc' 		=> __( '\'Post Formats\' add post formats, see <a href="http://codex.wordpress.org/Post_Formats">Post Formats</a>', 'jamnews' ),
					'id' 		=> 'supports_post-formats',
					'default'	=> (in_array("post-formats",$datas['supports'])?'yes':'no'),
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> 'end' ),
			
			array(	'title'		=> 'Taxonomies',
					'desc' 		=> __('<i> An array of registered taxonomies like category or post_tag that will be used with this post type.</i>', 'jamnews' ),
					'desc_tip'	=> true,
					'id' 		=> 'taxonomies',
					'name' 		=> 'taxonomies',
					'class'		=> 'span5 chosen_select',
					'type' 		=> 'multiselect',
					'default'	=> ( empty( $datas['taxonomies'] ) )?array():$datas['taxonomies'],
					'options'	=> get_taxonomies() ),
				   
			array( 'type' => 'sectionend')
		),
		
		'labels' => array(
			// Labels
			array(	'title' => __('Label Options',"jamnews"), 'type' => 'title' ),
			
			array( 	'name'	=> 'labels[name]',
					'title' => __('Name','jamnews'),
					'type' => 'text',
					'id' => 'labels_name',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('General name for the post type, usually plural.','jamnews'),
					'default' => (!$datas['labels']['name']||$datas['labels']['name']=="")?"":__( $datas['labels']['name'],"jamnews"),
					'custom_attributes' => array('placeholder' => __( "{$name}s","jamnews") ) ),
				   
			array( 	'name'	=>	'labels[singular_name]',
					'title' => __('Singular name','jamnews'),
					'type' => 'text',
					'id' => 'labels_singular_name',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('Name for one object of this post type. Defaults to value of name.','jamnews'),
					'default' =>  (!$datas['labels']['singular_name']||$datas['labels']['singular_name']=="")?"":__($datas['labels']['singular_name'],'jamnews'),
					'custom_attributes' => array('placeholder' => __($name,'jamnews') ) ),
			
			array( 	'name'	=> 'labels[menu_name]',
					'title' => __('Menu name','jamnews'),
					'type' => 'text',
					'id' => 'labels_menu_name',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The menu name text. This string is the name to give menu items. Defaults to value of name.','jamnews'),
					'default' => (!$datas['labels']['menu_name']||$datas['labels']['menu_name']=="")?"":$datas['labels']['menu_name'],
					'custom_attributes' => array('placeholder' => __($name,'jamnews') )),
				   
			array( 	'name' => 'labels[all_items]',
					'title' => __('All items','jamnews'),
					'type' => 'text',
					'id' => 'labels_all_items',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The all items text used in the menu. Default is the Name label.','jamnews'),
					'default' => (!$datas['labels']['all_items']||$datas['labels']['all_items']=="")?"":$datas['labels']['all_items'],
					'custom_attributes' => array('placeholder' => __($name,'jamnews') )),
				   
			array( 	'name'	=> 'labels[add_new]',
					'title' => __('Add new','jamnews'),
					'type' => 'text',
					'id' =>	'labels_add_new',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The add new text. The default is Add New for both hierarchical and non-hierarchical types.','jamnews'),
					'default' => (!$datas['labels']['add_new']||$datas['labels']['add_new']=="")?"":$datas['labels']['add_new'],
					'custom_attributes' => array('placeholder' => __("Add new {$name}",'jamnews') )),
				   
			array( 	'name'	=>	'labels[add_new_item]',
					'title' => __('Add new item','jamnews'),
					'type' => 'text',
					'id' => 'labels_add_new_item',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __(' the add new item text. Default is Add New Post/Add New Page.','jamnews'),
					'default' => (!$datas['labels']['add_new_item']||$datas['labels']['add_new_item']=="")?"":$datas['labels']['add_new_item'],
					'custom_attributes' => array('placeholder' => __("Add new {$name}",'jamnews') )),
				   
			array( 	'name'	=> 'labels[edit_item]',
					'title' => __('Edit item','jamnews'),
					'type' => 'text',
					'id' => 'labels_edit_item',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The edit item text. Default is Edit Post/Edit Page','jamnews'),
					'default' => (!$datas['labels']['edit_item']||$datas['labels']['edit_item']=="")?"":$datas['labels']['edit_item'],
					'custom_attributes' => array('placeholder' => __("Edit {$name}",'jamnews') )),
			
			array( 	'name'	=> 'labels[new_item]',
					'title' => __('New item','jamnews'),
					'type' => 'text',
					'id' => 'labels_new_item',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The new item text','jamnews'),
					'default' => (!$datas['labels']['new_item']||$datas['labels']['new_item']=="")?"":$datas['labels']['new_item'],
					'custom_attributes' => array('placeholder' => __("New {$name}",'jamnews') ) ),
			
			array( 	'name'	=> 'labels[view_item]',
					'title' => __('View item','jamnews'),
					'type' => 'text',
					'id' => 'labels_view_item',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The view item text. Default is View Post/View Page','jamnews'),
					'default' => (!$datas['labels']['view_item']||$datas['labels']['view_item']=="")?"":$datas['labels']['view_item'],
					'custom_attributes' => array('placeholder' => __("View {$name}",'jamnews') ) ),
			
			array( 	'name'	=> 'labels[search_items]',
					'title' => __('Search items','jamnews'),
					'type' => 'text',
					'id' => 'labels_search_items',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The search items text. Default is Search Posts/Search Pages','jamnews'),
					'default' => (!$datas['labels']['search_items']||$datas['labels']['search_items']=="")?"":$datas['labels']['search_items'],
					'custom_attributes' => array('placeholder' => __("Search {$name}",'jamnews') ) ),
			
			array( 	'name'	=> 'labels[not_found]',
					'title' => __('Not found','jamnews'),
					'type' => 'text',
					'id' => 'labels_not_found',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The not found text. Default is No posts found/No pages found.','jamnews'),
					'default' => (!$datas['labels']['not_found']||$datas['labels']['not_found']=="")?"":$datas['labels']['not_found'],
					'custom_attributes' => array('placeholder' => __("Search {$name}",'jamnews') ) ),

			array( 	'name'	=> 	'labels[not_found_in_trash]',
					'title' => __('Not found in trash','jamnews'),
					'type' => 'text',
					'id' => 'labels_not_found_in_trash',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __('The not found in trash text. Default is No posts found in Trash/No pages found in Trash.','jamnews'),
					'default' => (!$datas['labels']['not_found_in_trash']||$datas['labels']['not_found_in_trash']=="")?"":$datas['labels']['not_found_in_trash'],
					'custom_attributes' => array('placeholder' => __("No {$name}s found in Trash",'jamnews') ) ),
				   
			array( 	'name'	=> 'labels[parent_item_colon]',
					'title' => __('Parent item colon','jamnews'),
					'type' => 'text',
					'id' => 'labels_parent_item_colon',
					'class' => 'input-xlarge',
					'desc_tip' => true,
					'desc' => __(' the parent text. This string isn\'t used on non-hierarchical types. In hierarchical ones the default is Parent Page.','jamnews'),
					'default' => (!$datas['labels']['parent_item_colon']||$datas['labels']['parent_item_colon']=="")?"":$datas['labels']['parent_item_colon'],
					'custom_attributes' => array('placeholder' => __("Parent {$name}",'jamnews') ) ),
			
			array( 'type' => 'sectionend'),
		),
		'advanced' => array(
			// Advanced Options					
			array(	'title' => __('Advanced Options',"jamnews"), 'type' => 'title' ),
			
			array(	'title' => __('Menu icon',"jamnews"),
					'desc' 		=> __('Select icon to be used for this menu. <i>menu_icon</i>', 'jamnews' ),
					'id' 		=> 'menu_icon',
					'name' 		=> 'menu_icon',
					'class'		=> 'input-large',
					'type' 		=> 'upload',
					'default'	=>	$datas['menu_icon']),
					
			array(	'title' => __('Menu position',"jamnews"),
					'desc' 		=> __('The position in the menu order the post type should appear. show_in_menu must be true.', 'jamnews' ),
					'id' 		=> 'menu_position',
					'name'		=> 'menu_position',
					'class'		=> 'input-small',
					'type' 		=> 'text',
					'default'	=> $datas['menu_position'],
					'custom_attributes'=> array('placeholder'=>'5'), ),
					
			array(	'title' => __('Select options'),
					'desc' 		=> __('<strong>public:</strong> Whether a post type is intended to be used publicly either via the admin interface or by front-end users.', 'jamnews' ),
					'name'	=> 'public',
					'id' 		=> 'public',
					'default'	=> ($datas['public'])?'yes':"no",
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> 'start'),
			
			array(	'desc' 		=> __('<strong>exclude_from_search:</strong> <i>Whether to exclude posts with this post type from front end search results.</i>', 'jamnews' ),
					'name'		=> 'exclude_from_search',
					'id' 		=> 'exclude_from_search',
					'default'	=> ($datas['exclude_from_search'])?'yes':"no",
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
			
			array(	'desc' 		=> __('<strong>publicly_queryable:</strong> <i>Whether queries can be performed on the front end as part of parse_request().</i>', 'jamnews' ),
					'id' 		=> 'publicly_queryable',
					'name' 		=> 'publicly_queryable',
					'default'	=> $datas['publicly_queryable']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'desc' 		=> __('<strong>show_ui:</strong> <i>Whether to generate a default UI for managing this post type in the admin.</i>', 'jamnews' ),
					'id' 		=> 'show_ui',
					'name' 		=> 'show_ui',
					'default'	=> $datas['show_ui']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'desc' 		=> __('<strong>show_in_nav_menus
:</strong> <i>Whether to generate a default UI for managing this post type in the admin.</i>', 'jamnews' ),
					'id' 		=> 'show_in_nav_menus',
					'name' 		=> 'show_in_nav_menus',
					'default'	=> $datas['show_in_nav_menus']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
			
			array(	'desc' 		=> __('<strong>show_in_menu
:</strong> <i>Where to show the post type in the admin menu. show_ui must be true.</i>', 'jamnews' ),
					'id' 		=> 'show_in_menu',
					'name' 		=> 'show_in_menu',
					'default'	=> $datas['show_in_menu']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
			
			array(	'desc' 		=> __('<strong>show_in_admin_bar: </strong> <i>Whether to make this post type available in the WordPress admin bar.</i>', 'jamnews' ),
					'id' 		=> 'show_in_admin_bar',
					'name' 		=> 'show_in_admin_bar',
					'default'	=> $datas['show_in_admin_bar']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),

			array(	'desc' 		=> __('<strong>map_meta_cap :</strong> <i>  Whether to use the internal default meta capability handling.</i>', 'jamnews' ),
					'id' 		=> 'map_meta_cap',
					'name' 		=> 'map_meta_cap',
					'default'	=> $datas['map_meta_cap']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'desc' 		=> __('<strong>hierarchical :</strong> <i>  Whether the post type is hierarchical (e.g. page).</i>', 'jamnews' ),
					'id' 		=> 'hierarchical',
					'name' 		=> 'hierarchical',
					'default'	=> $datas['hierarchical']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'desc' 		=> __('<strong>can_export :</strong> <i> Can this post_type be exported.</i>', 'jamnews' ),
					'id' 		=> 'can_export',
					'name' 		=> 'can_export',
					'default'	=> $datas['can_export']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'desc' 		=> __('<strong>_builtin :</strong> <i> Whether this post type is a native or "built-in" post_type.</i>', 'jamnews' ),
					'id' 		=> '_builtin',
					'name' 		=> '_builtin',
					'default'	=> $datas['_builtin']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'desc' 		=> __('<strong>_edit_link :</strong> <i>  Link to edit an entry with this post type.</i>', 'jamnews' ),
					'id' 		=> '_edit_link',
					'name' 		=> '_edit_link',
					'default'	=> $datas['_edit_link']?'yes':'no',
					'type' 		=> 'checkbox',
					'checkboxgroup'		=> ''),
					
			array(	'title'		=> __('query_var'),
					'desc' 		=> __('<strong>query_var :</strong> <i>  Sets the query_var key for this post type.</i>', 'jamnews' ),
					'id' 		=> 'query_var',
					'name' 		=> 'query_var',
					'default'	=> (!$datas['query_var'])?'':$datas['query_var'],
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'custom_attributes' => array( 'placeholder' => $type ) ),
					
			array(	'title'		=> 'has_archive',
					'desc' 		=> __('<i>Will use $post_type as archive slug by default if this field is empty.</i>', 'jamnews' ),
					'id' 		=> 'has_archive',
					'name' 		=> 'has_archive',
					'class'		=> 'input-large',
					'type' 		=> 'text',
					'default' => (!$datas['has_archive'])?"":$datas['has_archive'],
					'custom_attributes' => array( 'placeholder' => $type ) ),
					
			array(	'title'		=> 'permalink_epmask',
					'desc' 		=> __('<i> The default rewrite endpoint bitmasks.</i>', 'jamnews' ),
					'id' 		=> 'permalink_epmask',
					'name' 		=> 'permalink_epmask',
					'class'		=> 'input-large',
					'default'	=> (!$datas['permalink_epmask']||$datas['permalink_epmask']=="")?"":$datas['permalink_epmask'],
					'type' 		=> 'text',
					'custom_attributes' => array( 'placeholder' => __("EP_PERMALINK",'jamnews') ) ),
					
			array( 'type' => 'sectionend'),
			
			array(	'title' => __('Rewrite',"jamnews"), 'type' => 'title' ),
			
			array(	'title'		=> 'slug',
					'desc' 		=> __('<i>Customize the permastruct slug. Defaults to the $post_type value.</i>', 'jamnews' ),
					'id' 		=> 'rewrite_slug',
					'name' 		=> 'rewrite[slug]',
					'class'		=> 'input-large',
					'default'	=> (!$datas['rewrite']['slug']||$datas['rewrite']['slug']=="")?"":$datas['rewrite']['slug'],
					'type' 		=> 'text',
					'custom_attributes' => array( 'placeholder' => $type ) ),
					
			array(	'title'		=> 'with_front',
					'desc' 		=> __('<i>Should the permastruct be prepended with the front base.</i>', 'jamnews' ),
					'id' 		=> 'rewrite_with_front',
					'name' 		=> 'rewrite[with_front]',
					'class'		=> 'input-large',
					'default'	=> ($datas['rewrite']['with_front'])?"yes":"no",
					'type' 		=> 'checkbox',
					'checkboxgroup'	=> 'start'),
					
			array(	'title'		=> 'feeds',
					'desc' 		=> __('<i>Should a feed permastruct be built for this post type. Defaults to has_archive value</i>', 'jamnews' ),
					'id' 		=> 'rewrite_feeds',
					'name' 		=> 'rewrite[feeds]',
					'class'		=> 'input-large',
					'default'	=> ($datas['rewrite']['feeds'])?"yes":"no",
					'type' 		=> 'checkbox',
					'checkboxgroup'	=> 'start' ),
					
			array(	'title'		=> 'pages',
					'desc' 		=> __('<i>Should the permastruct provide for pagination</i>', 'jamnews' ),
					'id' 		=> 'rewrite_pages',
					'name' 		=> 'rewrite[pages]',
					'class'		=> 'input-large',
					'default'	=> ($datas['rewrite']['pages'])?"yes":"no",
					'type' 		=> 'checkbox',
					'checkboxgroup'	=> 'start' ),
					
			array(	'title'		=> 'ep_mask',
					'desc' 		=> __('<i>As of 3.4 Assign an endpoint mask for this post type.</i>', 'jamnews' ),
					'id' 		=> 'rewrite_ep_mask',
					'name' 		=> 'rewrite[ep_mask]',
					'class'		=> 'input-large',
					'default'	=> (!$datas['rewrite']['ep_mask']||$datas['rewrite']['ep_mask']=="")?"":$datas['rewrite']['ep_mask'],
					'type' 		=> 'text',
					'custom_attributes' => array( 'placeholder' => 'EP_PERMALINK' ) ),
					
			array( 'type' => 'sectionend'),
		),
		
		'capabilities' => array(
			
			array(	'title' => __('Capabilities',"jamnews"), 'type' => 'title' ),
		
			array(	'title'		=> __('Capability type','woothemes'),
					'desc_tip' => true,
					'desc' 		=> __('<i>The string to use to build the read, edit, and delete capabilities.</i>', 'jamnews' ),
					'id' 		=> 'capability_type',
					'name' 		=> 'capability_type',
					'type' 		=> 'text',
					'default'	=> ($capability_type=='post')?'':$capability_type,
					'custom_attributes' => array( 'placeholder' => $capability_type ) ),
			
			array(	'title'		=> __('edit_post','woothemes'),
					'id' 		=> 'capabilities_edit_post',
					'name' 		=> 'capabilities[edit_post]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['edit_post'],
					'custom_attributes' => array( 'placeholder' => "edit_{$capability_type}" ) ),
					
			array(	'title'		=> __('read_post','woothemes'),
					'id' 		=> 'capabilities_read_post',
					'name' 		=> 'capabilities[read_post]',
					'type' 		=> 'text',
					'class'		=> 'input-large' ,
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['read_post'],
					'custom_attributes' =>  array( 'placeholder' => "read_{$capability_type}" ) ),
					
			array(	'title'		=> __('delete_post','woothemes'),
					'id' 		=> 'capabilities_delete_post',
					'name' 		=> 'capabilities[delete_post]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['delete_post'],
					'custom_attributes' =>  array( 'placeholder' => "delete_{$capability_type}" ) ),
					
			array(	'title'		=> __('edit_posts','woothemes'),
					'id' 		=> 'capabilities_edit_posts',
					'name' 		=> 'capabilities[edit_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['edit_posts'],
					'custom_attributes' =>  array( 'placeholder' => "edit_{$capability_type}s" ) ),
					
			array(	'title'		=> __('edit_others_posts','woothemes'),
					'id' 		=> 'capabilities_edit_others_posts',
					'name' 		=> 'capabilities[edit_others_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['edit_others_posts'],
					'custom_attributes' =>  array( 'placeholder' => "edit_others_{$capability_type}s" ) ),
					
			array(	'title'		=> __('publish_posts','woothemes'),
					'id' 		=> 'capabilities_publish_posts',
					'name' 		=> 'capabilities[publish_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['publish_posts'],
					'custom_attributes' =>  array( 'placeholder' => "publish_{$capability_type}s" ) ),
					
			array(	'title'		=> __('read_private_posts','woothemes'),
					'id' 		=> 'capabilities_read_private_posts',
					'name' 		=> 'capabilities[read_private_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['read_private_posts'],
					'custom_attributes' =>  array( 'placeholder' => "read_private_{$capability_type}s" ) ),
					
			array(	'title'		=> __('delete_posts','woothemes'),
					'id' 		=> 'capabilities_delete_posts',
					'name' 		=> 'capabilities[delete_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['delete_posts'],
					'custom_attributes' =>  array( 'placeholder' => "delete_{$capability_type}s" ) ) ,
			
			array(	'title'		=> __('delete_private_posts','woothemes'),
					'id' 		=> 'capabilities_delete_private_posts',
					'name' 		=> 'capabilities[delete_private_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['delete_private_posts'],
					'custom_attributes' =>  array( 'placeholder' => "delete_private_{$capability_type}s" ) ) ,
					
			array(	'title'		=> __('delete_published_posts','woothemes'),
					'id' 		=> 'capabilities_delete_published_posts',
					'name' 		=> 'capabilities[delete_published_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['delete_published_posts'],
					'custom_attributes' =>  array( 'placeholder' => "delete_published_{$capability_type}s" ) ) ,
					
			array(	'title'		=> __('delete_others_posts','woothemes'),
					'id' 		=> 'capabilities_delete_others_posts',
					'name' 		=> 'capabilities[delete_others_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['delete_others_posts'],
					'custom_attributes' =>  array( 'placeholder' => "delete_others_{$capability_type}s" ) ) ,
					
			array(	'title'		=> __('edit_private_posts','woothemes'),
					'id' 		=> 'capabilities_edit_private_posts',
					'name' 		=> 'capabilities[edit_private_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['edit_private_posts'],
					'custom_attributes' =>  array( 'placeholder' => "edit_private_{$capability_type}s" ) ) ,
			
			array(	'title'		=> __('edit_published_posts','woothemes'),
					'id' 		=> 'capabilities_edit_published_posts',
					'name' 		=> 'capabilities[edit_published_posts]',
					'type' 		=> 'text',
					'class'		=> 'input-large',
					'default'	=> ($capability_type=="post")?'':$datas['capabilities']['edit_published_posts'],
					'custom_attributes' =>  array( 'placeholder' => "edit_published_{$capability_type}s" ) ) ,
					
			array( 'type' => 'sectionend'),
		)
	);		
	?>
	<div class="wrap jamnews">
		<div id="icon-edit" class="icon32 icon32-posts-post"><br /></div>
		<h2>
			<?php echo __("Add New Post Types",'jamnews');?>
		</h2>
		
		<form method="post" id="addform" class="updateform" action="" enctype="multipart/form-data">
			<?php wp_nonce_field( 'jamnews_admin_save_posttype', '_wpnonce', true, true );?>
			<textarea id="groupfield_json" name="groupfield_json"></textarea>
			<input name="current_tab" id="current_tab" type="hidden" value="<?php echo _val("current_tab"); ?>" />
			<div id="poststuff">
				<div id="post-body-content">
					<!-- Begin tab -->
					<ul class="nav nav-tabs">
					<?php $count=0; foreach($tab_labels as $key => $value){ 
						$active = ( ($current_tab=="")&&($count==0)||($current_tab!="")&&($key==$current_tab) )?" class='active'":"";
					?>
						<li <?php echo $active;?>>
							<a href="#<?php echo $key; ?>" data-toggle="tab"><?php echo $value; ?></a>
						</li>
					<?php $count++; } ?>
					</ul>
					<div class="tab-content">
						<input name="jamnews_id_post_type" id="jamnews_id_post_type" type="hidden" value="<?php echo $pt->id;?>" />
						
						<?php $count = 0; foreach($tab_fields as $key => $tab_content){ 
							$active = ( ($current_tab=="")&&($count==0)||($current_tab!="")&&($key==$current_tab) )?" active":"";
						?>
						<div class="tab-pane<?php echo $active;?>" id="<?php echo $key;?>">
							<?php jamnews_admin_fields($tab_content)?>
						</div>
						<?php $count++; } ?>
						
						<!-- Tab groups and fields -->
						<div class="tab-pane <?php echo ($current_tab=="fields"?"active":"");?>" id="fields">
							<div id="jwfields" class="content">
								<div class="sidebar">
									<div class="sidebar-dropdown"><a href="#">Navigation</a></div>
									<ul id="nav">
										<!-- Main menu with font awesome icon -->
										<li class="draggable groups" data_type="group">
											<a class="open"><i class="icon-list-alt"></i> <?php echo __("Group","jamnews")?> <input type="text" class="group-name input-small"/></a>
											<div class="widget hide">
												<!-- Widget head -->
												<div class="widget-head">
													<div class="pull-left">
														<a href="javascript:void();" ><i class="icon icon-move"></i></a> Group <input type="text" class="group-name change-name">
													</div>
												  <div class="widget-icons pull-right">
													<a class="wminimize gminimize" href="#"><i class="icon-chevron-up"></i></a> 
													<a class="wclose gclose" href="#"><i class="icon-remove"></i></a>
												  </div>  
												  <div class="clearfix"></div>
												</div>              

												<!-- Widget content -->
												<div class="widget-content" style="display:none;">
													<div class="padd">
														<ul class="container">
															
														</ul>
													</div>
												</div>
												<!-- Widget ends -->
											</div>
										</li>
										
										<?php 
										$fiedls = apply_filters( "jamnews_fields", array() );
										foreach($fiedls as $field){
											$field->display();
										}
										?>
										<li  class="draggable fields" data_type="field"><a><i class="icon-bar-chart"></i> Field: Text</a>
											<div class="html-field row-fluid hide">
												<div class="span1">Text</div>
												<div class="span3"><input type="text" /></div>
												<div class="span3"><input type="text" /></div>
												<div class="span3"></div>
												<div class="span1"><a href="javascript:void();"><i class="icon icon-ok color-green"></i></a> </div>
												<div class="span1"><a href="javascript:void();"><i class="icon icon-remove  color-red"></i></a></div>
											</div>
										</li> 
										<li><a><i class="icon-table"></i> Field: Number</a></li>
										<li><a><i class="icon-tasks"></i> Field: Image</a></li>
										<li><a><i class="icon-magic"></i> Field: Select</a></li>
									</ul>
								</div>
								
								
								<div class="mainbar">
									<div class="page-head">
										<h2 class="pull-left"><i class="icon-tasks"></i> <?php echo __("Manager Fields/Groups","jamnews")?></h2>
										<div class="clearfix"></div>
									</div>
									
									<div class="matter">
										<div class="container-fluid">
											<div class="row-fluid">
												<ul id="container-groups" class="span12">
													
												</ul>
											</div>
										</div>
									</div>
								</div>
								
								<div class="clearfix"></div>
							</div>
						</div>
						<!-- End tab group and field -->
					</div>
					<!-- End tab-content -->
					<br/>
					<div class="btn-groups">
						<input type="submit" name="btn-add-post-type" class="btn" value="<?php echo __("Save change","jamnews")?>" />
						<a href="?page=<?php echo $_GET['page']?>&action=add" class="btn btn"><i class="icon icon-plus"></i> <?php echo __("Add new","jamnews");?></a>
					</div>
				</div>
			</div>
		</form>
		<script>
		jQuery(function($){
			// Select current tab onsubmit
			$('a[data-toggle="tab"]').on('shown', function (e) {
				$("#current_tab").val($(this).attr("href").replace("#",""));
			})
		});
		</script>
	</div>
	<?php
}
?>